#include <iostream>

using std::cout;
using std::endl;

class Base
{
public:
    Base(long base): _base(base) 
    {  cout << "Base(long)" << endl;    }

    virtual
    void print() const
    {   cout << "_base:" << _base << endl;}

    //在成员函数中调用虚函数, 展现动态联编
    void func1()
    {   
        cout << "func1()" << endl;
        //this指针是Base* const this
        this->print();    
    }

    void func2()
    {   
        cout << "func2()" << endl;
        Base::print();  
    }

private:
    long _base;
};

class Derived
: public Base
{
public:
    Derived(long base, long derived)
    : Base(base)
    , _derived(derived)
    {   cout << "Derived1(long,long)" << endl;}

    void print() const  override
    {   cout << "Derived1::_derived:" << _derived << endl;    }


private:
    long _derived;
};


int main()
{
    Base base(1);
    base.func1();
    cout << endl;

    Derived d1(10, 100);
    d1.func1();//发生了动态多态
    d1.func2();//静态联编
    return 0;
}

